﻿using Iworld.Backstage.Framework.GameService;
using Iworld.Toolkit.Helper;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Iworld.Backstage
{
    public partial class GameChapterDetailWindow : ChildWindow
    {

        public GameChapterDetailWindow()
        {
            InitializeComponent();
        }

        public Visibility IsEdited
        {
            get { return (Visibility)GetValue(IsEditedProperty); }
            set { SetValue(IsEditedProperty, value); }
        }

     
      
        public static readonly DependencyProperty IsEditedProperty =
            DependencyProperty.Register("IsEdited", typeof(Visibility), 
            typeof(GameChapterDetailWindow), new PropertyMetadata(Visibility.Collapsed));



        public ObservableCollection<GameRoundExport> List
        {
            get { return (ObservableCollection<GameRoundExport>)GetValue(ListProperty); }
            set { SetValue(ListProperty, value); }
        }

          public static readonly DependencyProperty ListProperty =
            DependencyProperty.Register("List", typeof(ObservableCollection<GameRoundExport>), typeof(GameChapterDetailWindow), new PropertyMetadata(null));

        public GameChapterExport GameChapter
        {
            get { return (GameChapterExport)GetValue(GameChapterProperty); }
            set { SetValue(GameChapterProperty, value); }
        }

        public static readonly DependencyProperty GameChapterProperty =
            DependencyProperty.Register("GameChapter", typeof(GameChapterExport), typeof(GameChapterDetailWindow), 
            new PropertyMetadata(null, (sender,args) => 
            {
                GameChapterDetailWindow win = sender as GameChapterDetailWindow;
                GameChapterExport info = args.NewValue as GameChapterExport;
                //win.Dg.ItemsSource = info.GameRounds;
                win.List = info.GameRounds;
                if(info.Status == GameChapterStatus.从未开奖 && info.ActiveTime == null)
                {
                    win.IsEdited =  Visibility.Visible;
                }
           
            }));


        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Enter(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            GameRoundExport ge = XamlHelper.GetDataContext<GameRoundExport>(sender);
            EditGameRoundWindow w = new EditGameRoundWindow();
            w.GameRoundInfo = ge;
            w.Show();
        }

       
    }
}

